﻿using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            BiTree bt = new BiTree() { Str = "ABDH...EJ...CF..." };
            bt.CreateBiTreeByString(bt.Root);

            bt.PreOrder(bt.Root);
            Console.WriteLine();
            bt.InOrder(bt.Root);
            Console.WriteLine();
            bt.PostOrder(bt.Root);
            Console.WriteLine();

            Console.WriteLine("总节点数:{0}", bt.GetNodeNums(bt.Root));
            Console.WriteLine("左子数总节点数:{0}", bt.GetNodeNums(bt.Root.CLeft));

            Console.WriteLine("叶子节点:{0}", bt.GetYeziNums(bt.Root));

            int depth = bt.GetDepth(bt.Root);
            Console.WriteLine("统计高度:{0}", depth);

            for (int i = 1; i <= depth; i++)
            {
                Console.WriteLine("{1}层节点数量:{0}",
                    bt.GetLevelsNums(bt.Root, i), i);
            }

            bt.Root = bt.ReturnPostOrder("ABDHEJCF", "HDBJEAFC");
            Console.Write("推导后的后序打印");
            bt.PostOrder(bt.Root);
            Console.WriteLine();

            bt.ExchangeChildren(bt.Root);
            Console.Write("左右子树交换后的先序打印");
            bt.PreOrder(bt.Root);
            bt.ExchangeChildren(bt.Root);
            Console.WriteLine();
            
            bt.PreOrder2(bt.Root);
            Console.WriteLine();
            bt.InOrder2(bt.Root);
            Console.WriteLine();


        }
    }
}
